package com.example.jiagoujiexiang.Mapper;


import com.example.jiagoujiexiang.entity.User;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;
@Mapper
@Repository
public interface UserDao {
    @Select( "select * from user ")
    public List<User> getUserList();

    @Select("select * from user where username = #{num}")
    public User getUserByNum(@Param("num")String num);

    @Select("select * from user where id = #{id}")
    public User getUserByid(@Param("id")int id);


    @Insert("INSERT INTO user(username,password,userType,telephone,sex,name) VALUES (#{user.username},#{user.passwordSecret},#{user.userType},#{user.telephone},#{user.sex},#{user.name})")
    public int insertUser(@Param("user")User user);

    @Delete("DELETE FROM user WHERE id = #{userId}")
    public int deleteUser(@Param("userId")int userId);

    @Update("UPDATE user SET username=#{user.username}, password=#{user.password}, userType=#{user.userType}, telephone=#{user.telephone}, sex=#{user.sex}, name=#{user.name} WHERE id=#{user.id}")
    public int updateUser(@Param("user")User user,User user2);

    @Update("UPDATE user SET username= #{user.username}, password=#{user.passwordSecret},telephone=#{user.telephone}, sex=#{user.sex}, name=#{user.name} WHERE id= #{user.id}")
    public int updateUseradmin(@Param("user")User user);
}
